// Lang_33 [interfaces II].nova // Show that an interface does not get broken with inheritance. // The application class. class InterfacesIIApp { // Application class's "main" function. public static void main( String[] args ) { Stream.writeLine( "App.main( ) - called" ); // Create a new object using a concrete class and assign to an interface reference. IFourMethods a = new ConcreteClass2( ); // Call a virtual method using the abstract class reference. a.m0( ); // Call a virtual method using the abstract class reference. a.m1( ); // It is not possible to instantiate a new object using an abstract class. // AbstractClass abstractClass = new AbstractClass( ); } } // Declare an example interface with four methods. interface IFourMethods { public void m0( ); public void m1( ); public void m2( ); public void m3( ); } // Declare an extra interface. interface IExtra { public void extraMethod( ); } // Concrete class. class ConcreteClass { public virtual void m1( ) { Stream.writeLine( "ConcreteClass.m1( ) - called" ); } } // Concrete class 2. class ConcreteClass2 : ConcreteClass, IFourMethods, IExtra, IRun { public virtual void m0( ) { Stream.writeLine( "ConcreteClass2.m0( ) - called" ); } public virtual void m2( ) { Stream.writeLine( "ConcreteClass2.m2( ) - called" ); } public virtual void m3( ) { Stream.writeLine( "ConcreteClass2.m3( ) - called" ); } public virtual void extraMethod( ) { Stream.writeLine( "ConcreteClass2.extraMethod( ) - called" ); } public virtual Object run( Object arg ) { Stream.writeLine( "ConcreteClass2.run( ) - called" ); return null; } }